﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace Bohdan.Arch.Messaging
{
    public abstract class FormSubscriber : GeneralSingleThreadedSubscriber
    {
        protected Form _form;

        private void ProperProcessMessageCaller(object msg)
        {
            base.ProcessMessageImmediateCaller((GeneralMessage)msg);
        }

        protected override void ProcessMessageImmediateCaller(GeneralMessage msg)
        {
            _form.Invoke(new ParameterizedThreadStart(ProperProcessMessageCaller), msg);
        }

        public override ThreadPriority WorkerThreadPriority
        {
            get
            {
                return ThreadPriority.Normal;
            }
        }

        public FormSubscriber(Form form)
        {
            this._form = form;
        }
    }
}
